home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / asg.com / BLUEBAG.DOC < prev    next >
Encoding:
Text File  |  1989-07-16  |  8.1 KB  |  190 lines

  1. Documentation for the BlueBag Unit - Version 5.2
  2.  
  3. This unit of handy procedures was compiled for Turbo Pascal version 5.0
  4. Routines are available for modifying the cursor, CRT tricks, dates, string
  5. processing, testing printer status, and multiple overlapping windows. This
  6. updated unit was largely rewritten in Assembler for reduced size and faster
  7. performance. Desirable in itself this unit is essential for the AtSayGet
  8. line editing procedures available in the ATSAY52.ARC file. The interface and
  9. dependencies are noted below followed by an explanation of each routine.
  10.  
  11. UNIT BlueBag;
  12.  
  13. INTERFACE
  14. USES
  15.  Crt,DOS;
  16.  
  17. TYPE
  18.  Date = LONGINT;
  19.  DateString = STRING[8]; {'MoDyYear' expected. eg: '07041776' = Independence}
  20.  DofW = 1..7;
  21.  LptRange=0..2;
  22.  MofY = 1..12;
  23.  Xrange=1..80;
  24.  Yrange=1..25;
  25. CONST
  26.  BadDate = $7FFFFFFF;
  27.  DayName : ARRAY[DofW] OF STRING[9] =
  28.   ('Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday');
  29.  MonthName : ARRAY[MofY] OF STRING[9] =
  30.   ('January','February','March','April','May','June','July','August',
  31.    'September','October','November','December');
  32. VAR
  33.  IsColor   : BOOLEAN;      {Display mode at startup}
  34.  StartScan,
  35.  StopScan  : BYTE;         {Cursor shape at startup}
  36.  
  37. {cursor procedures}
  38. PROCEDURE CursorSave;                          {obj code}
  39. PROCEDURE CursorOn;                            {obj code}
  40. PROCEDURE CursorOff;                           {obj code}
  41. PROCEDURE RestoreCursor;                       {obj code}
  42. PROCEDURE SetCursor(ScanStart,ScanStop:BYTE);  {obj code}
  43. {CRT procedures}
  44. PROCEDURE CLEAR(X1,Y1,X2,Y2:INTEGER);
  45. PROCEDURE DrawBox(X1,Y1,X2,Y2,LineStyle:BYTE);
  46. PROCEDURE RestoreVideo;
  47. PROCEDURE ReverseVideo;
  48. PROCEDURE WAIT;
  49. {date functions}
  50. FUNCTION DateStringToDate(DS:DateString):Date;
  51. FUNCTION DateToDateString(DT:Date):DateString;
  52. FUNCTION DaysBetween(Early,Late:Date);LongInt;
  53. FUNCTION DayOfWeek(DT:Date):DofW;
  54. FUNCTION IncDate(DT:Date; Delta:Longint):Date;
  55. FUNCTION MonthOfYear(DT:Date):MofY;
  56. FUNCTION SysDate:Date;
  57. FUNCTION ValidDate(DS:DateString):BOOLEAN;
  58. {string procedures}
  59. FUNCTION  IsBlank(TextStr:STRING):BOOLEAN;
  60. PROCEDURE NoBlanks(VAR HasBlanks:STRING);
  61. FUNCTION  Trim(LongLine:STRING):STRING;
  62. FUNCTION  UpperCase(S:STRING):STRING;          {obj code}
  63. {device procedures}
  64. FUNCTION  OnFile(FileName:STRING):BOOLEAN;
  65. FUNCTION  PrinterOnLine(LPTnum:LptRange):BOOLEAN;  {obj code}
  66. {window procedures}
  67. PROCEDURE OpenWindow(TX:Xrange; TY:Yrange; {Top left corner coordinates     }
  68.                      BX:Xrange; BY:Yrange; {Bottom right corner coordinates }
  69.                      FRG,BKG,              {Color of text and background    }
  70.                      Border : BYTE;        {Border style                    }
  71.                      Heading: STRING);     {Window heading at top of frame  }
  72. PROCEDURE CloseWindow;
  73.  
  74. (* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)
  75.  
  76.  Alphabetical listing of BLUEBAG procedures and functions and an explanation
  77.  of the purpose of each:
  78.  
  79.  
  80. CLEAR clears screen area defined by the coordinates using current text
  81. attribute. It is relative to any window that may be open.
  82. eg: Clear(5,5,10,10); {clears screen fron 5,5, to 10,10}
  83.  
  84. CLOSEWINDOW restores the image under the current window and frees the heap
  85. space that was used to store it.
  86. eg: CloseWindow; {closes the last window that was opened}
  87.  
  88. CURSOROFF turns off the cursor after saving the current cursor shape in
  89. StartScan and StopScan. A call to RESTORECURSOR will reset it to its shape
  90. before being turned off.
  91. eg: CursorOff; {hides the cursoe}
  92.  
  93. CURSORON sets the cursor to the default setting for the monitor in use at
  94. startup.
  95. eg: CursorOn; {turns on the cursor}
  96.  
  97. CURSORSAVE saves the current cursor start and stop scan lines into the global
  98. variables StartScan and StopScan.
  99. eg: CursorSave; {saves the cursor shape}
  100.  
  101. DATESTRINGTODATE returns a (LongInt) Date from a (STRING[8]) DateString.
  102. eg: DateToDateString('07041776') returns 648869.
  103.  
  104. DATETODATESTRING returns a (STRING[8]) DateString from a (LongInt) Date.
  105. eg: DateToDateString(648869) returns '07041776'.
  106.  
  107. DAYSBETWEEN returns the number of days between the early and late dates.
  108. eg: DaysBetween(DateStringToDate('07041776'),DateToDateString('07041989'))
  109.     returns 77,796 (days).
  110.  
  111. DAYOFWEEK returns the ordinal day of week from a LongInt Date; 1=Friday, etc.
  112. eg: CanadaDay:DateString='07011867';
  113.     DayOfWeek(DateStringToDate(CanadaDay)) returns 4 and
  114.     DayName[DayOfWeek(DateStringToDate(CanadaDay))] returns 'Tuesday'.
  115.  
  116. DRAWBOW draws a box defined by the coordinates. LineStyles are 1 (single),
  117. 2 (double), or 32..254 (ASCII #32..#254).
  118. eg: DrawBox(5,5,10,10,219); {draws a box from 5,5, to 10,10 in CHR(219) = █ }
  119.  
  120. INCDATE incriments a (LongInt) Date by delta days.
  121.  
  122. ISBLANK returns True if the string has is nul or all spaces, or False if the
  123. string has at least one character.
  124. eg: IsBlank('Something is here') is False;   IsBlank('     ') is True;
  125.  
  126. MONTHOFYEAR returns the ordinal month of a (LongInt) Date.
  127. eg: MonthName[MonthOfYear(648869)] gives 'July'.
  128.  
  129. NOBLANKS removes all blanks from a string.
  130. eg: SomeStr:STRING='JUNK 1      ';
  131.     SomeStr:=SomeStr+'.BAK';      (* Now SomeStr = 'JUNK 1      .BAK' *)
  132.     NoBlanks(SomeStr);            (* Now SomeStr = 'JUNK1.BAK' *)
  133.  
  134. ONFILE returns True if specified file exists. FileName defaults to the current
  135. directory or looks to the path specified.
  136. eg: OnFile('\UTIL\PCTOOLS.EXE') OR OnFile('PCTOOLS.EXE') results in True if
  137.     PCTOOLS.EXE is in the \util or current directory, otherwise returns False.
  138.  
  139. OPENWINDOW first stores the screen display within the coordinates specified
  140. and saves the image on the heap. It then draws a border using a border style
  141. and TextAttrs specified in the parameters. An optional title is permitted at
  142. the top of the window. A window is then opened within the border and the
  143. screen cleared. Up to 9 windows may be opened and they can overlap.
  144. eg: OpenWindow(5,5,50,12,White,Red,1,' HI MOM ') draws a single line frame
  145.     in white on a red background from 5,5 to 50,12 and opens a window within
  146.     the borders. The words ' HI MOM ' are centered at the top of the border.
  147.  
  148. PRINTERONLINE returns True if printer port status reports ready, else False.
  149. LPTnum RANGE IS 0..2 corresponding to the printer ports 1..3
  150. eg: PrinterOnLine(0) is False if you don't have a printer on port 1 or if you
  151.     do but the printer is off line. Tests out fine on Epson but other printers
  152.     may not respond as expected.
  153.  
  154. RESTORECURSOR restores the cursor to the shape it had before being turned off
  155. by the CursorOff procedure or modified by the SetCursor procedure.
  156. eg: RestoreCursor;
  157.  
  158. RESTOREVIDEO restores the video attribute to the condition before calling the
  159. ReverseVideo procedure (See below).
  160.  
  161. REVERSEVIDEO displays black charactors on light background on a mono screen;
  162. On color screens it displays a suitable dark colored charactor on light b/g.
  163.  
  164. SETCURSOR sets cursor start and stop scans for altering cursor shape.
  165. SetCursor(StartScan,StopScan) will always display a block cursor regardless of
  166. the monitor used.
  167. eg: SetCursor(5,6); { If used on a mono screen the cursor will be a dash "-" }
  168.  
  169. SYSDATE returns a (Longint) Date from the system clock; The result varies
  170. depending on the system date.
  171.  
  172. TRIM returns a string with any leading or trailing spaces removed.
  173. eg: Tight:=Trim(' and then she said   '); { Tight = 'and then she said' }
  174.  
  175. UPPERCASE returns a string in uppercase. Corrected version of assembly code
  176. listed on pgs 213-4 of the TP5 manual.
  177. eg: Uppidy:=UpperCase('and then she said'); { Uppidy='AND THEN SHE SAID' }
  178.  
  179. VALIDDATE returns True if the DateString is valid, else False.
  180. eg: ValidDate('02291988') returns True but
  181.     ValidDate('02291989') returns False (because 1989 is not a leapyear).
  182.  
  183. WAIT turns off cursor, prints the message 'Press any key to continue' at the
  184. current cursor location, waits for any key to be pressed, and then restores
  185. the cursor.
  186. eg: Wait;  { Displays: Press any key to continue }
  187.  
  188. (* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)
  189.  
  190. {See Demo.pas for some examples of how to use the routines in this unit}